const timeReg = /\[(\d{2}):(\d{2})\.(\d{2,3})\]/i

export function formatLyric(lyricStr) {
	const lyricInfos = []
	const lyricLines = lyricStr.split("\n")
	for (const lineString of lyricLines) {
		const results = lineString.match(timeReg)
		if (!results) continue
		const minute = results[1] * 60 * 1000
		const sescnd = results[2] * 1000
		const mSecond = results[3].length === 2 ? results[3] * 10 : results[3] * 1
		const time = minute + sescnd + mSecond
		const text = lineString.replace(timeReg, "")
		if (text != '') {
			lyricInfos.push({
				time,
				text
			})
		}
		
	}
	return lyricInfos
}
